package service

import (
	"context"

	stage "stage/hertz_gen/stage"
	. "stageRpc/client"
	stageRpcModel "stageRpc/kitex_gen/stage"

	"github.com/cloudwego/hertz/pkg/app"
	"github.com/jinzhu/copier"
)

type GetDeskInfoService struct {
	RequestContext *app.RequestContext
	Context        context.Context
}

func NewGetDeskInfoService(Context context.Context, RequestContext *app.RequestContext) *GetDeskInfoService {
	return &GetDeskInfoService{RequestContext: RequestContext, Context: Context}
}

func (h *GetDeskInfoService) Run(req *stage.Desk) (resp *stage.Desk, err error) {
	var desk = new(stageRpcModel.Desk)
	err = copier.Copy(desk, req)
	if err != nil {
		return nil, err
	}
	d, err := StageClient.GetDeskInfo(context.Background(), desk)
	if err != nil {
		return nil, err
	}
	resp = new(stage.Desk)
	err = copier.Copy(resp, d)
	if err != nil {
		return nil, err
	}
	return
}
